<?php
//这是HTTP操作模块

class Http extends spController
{
	function __construct(){ // 公用
		parent::__construct(); // 这是必须的
		$system = spClass("system");
		$sys=$system->findAll();
		$this->tpl_title = $sys[0][name];
		$this->email = $_SESSION["userinfo"]["mail"];
	}
	
//添加网站	
	function addsite()
	{
		$this->contents = "添加网站";
		$user = spClass('user');
		$this->value=$user->u_status();
		//$this->ssdd = $_SESSION["userinfo"]["acl"];		
		$this->display("member/main_add.html");
	}
	
	function insert() 
	{
		$data = $this->spArgs ();
		if($data['mclass']=='http')
		{
			$site = spClass ( 'site' );
		}else{
			$site = spClass ( 'psite' );
		}
		$rows = array 
		(
			'domain' => $data ['domain'], 
			'title' => $data ['title'] 
		);
		$results = $site->spVerifier ( $rows );
		if (false == $results) 
		{
			if($site->insert ( $data ))
			{
				$this->success('添加成功',spUrl("main","addsite"));
			}
		} else 
		{
			foreach ( $results as $item ) 
			{
				foreach ( $item as $msg ) 
				{
					$this->error ( $msg, spUrl ( "main", "addsite" ) );
				}
			}
		}
	}
	
	function record()
	{
		$siteid = $this->spArgs('siteid');
		
		$conditions = "status_code<>200 and siteid = '$siteid'";		
		$record = spClass('record');
		$this->results = $record->spLinker()->spPager($this->spArgs('page', 1), 10)->findAll($conditions);
		$this->pager = $record->spPager()->getPager();
		
		$this->fault = $record->one_fault($siteid);
		$this->normal = $record->one_normal($siteid);
		$this->siteid=$siteid;
		$this->title=$this->spArgs("title");
		$this->domain = $this->spArgs("domain");
		
		$d_time = spClass('my_fun');
		$t = date("Y-m-d H:i:s",strtotime("0 month"));		
		$f = $d_time->TheMonth($t);
		$this->tmonth=$f;
		$this->nmonth=$d_time->TheMonth(date("Y-m-d H:i:s",strtotime("-1 month")));
		$this->cmonth=$d_time->TheMonth(date("Y-m-d H:i:s",strtotime("-2 month")));
		$this->contents = "网站检测记录详情";
		$this->display("member/main_record.html");
		
	}
	
}	